<template>
  <component
    :is="tag"
    class="share-it666"
    @click="navSharePoster"
  >
    <slot />
  </component>
</template>

<script lang="ts">
import Vue from 'vue'
// import NativeShare from 'nativeshare'
// import { setShareData, showShare } from 'lib/share/share'
export default Vue.extend({
  props: {
    tag: {
      type: String,
      default: 'span',
    },
    subject: {
      type: String,
      default: '',
    },
    // goPoster2: {
    //   type: Boolean,
    //   default: false,
    // },
  },
  methods: {
    navSharePoster () {
      const userInfo = this.$store.state.userInfo
      let path = this.$route.fullPath
      let query = {
        name: this.$route.name!,
        subj: this.subject || this.$route.query.subj || document.title,
        uname: userInfo.RealName || userInfo.Phone,
      } as any
      if (this.$route.meta.setSharePage === 2) {
        const { fromApp, ...othQuery } = this.$route.query
        if (othQuery) {
          query = {
            ...othQuery,
            ...query,
          }
        }
      } else {
        query.url = path
      }
      this.$router.push({
        // name: this.goPoster2 ? 'anotherPoster' : 'poster',
        name: 'anotherPoster',
        query,
      })
    },
  },
})
</script>
